#ifndef BASEDAV_H
#define BASEDAV_H
//
#include "base_modul.h"
#include "qxml.h"
#include "main.h"
//

#include "networkdav.h"
#include "davdelete.h"
#include "davmkcol.h"
#include "davpropfind.h"
#include "davput.h"
#include "gui_remove.h"

/////////////////#include "davdirrecursive.h"

class File_Ram: public QObject, public Base_Modul
{
    Q_OBJECT
//
public: 
    File_Ram( QFileInfo fi , const QString remotefile , QString path )
{
   pathi = path;
   remotefilename = remotefile;
   file = fi;  /* QFileInfo */
   fullpath = fi.absoluteFilePath();
   filename = fi.fileName();
   BeamUpFile = new QFile(fi.absoluteFilePath()); 
   if (BeamUpFile->open(QIODevice::ReadOnly))  {
     /* set ram for permission not delete... */  
     enables = true;  
   } else {
     enables = false;  
   }
    qDebug() << "#### Register ->" << fi.absoluteFilePath() << " read ? " << enables;
}
inline QFile * GetFile() { return BeamUpFile; }
inline bool Permission() { return enables; }
inline QString GetRemoteFile() const { return remotefilename; }
inline QString GetPath() const { return pathi; }
protected:
    QFile *BeamUpFile;
private:
    bool enables;
    QString pathi;
    QString filename;
    QString remotefilename;
    QString fullpath;
    QFileInfo file;
signals:
public slots:
};



/*  Save file as basedav.h  */
/*  incomming class name BaseDav */
//
//

class DavPROPFIND;
    
class BaseDav : public QObject, public Base_Modul
{
     Q_OBJECT
//
public:	 
    BaseDav( NetworkDav * db , QWidget * parent );
    void OpenDir( QString dir , bool newfile );
    void RemoveDirorFileDav( QString removepath );
//
protected:
    
    
    void MkDirRecursiveFiDi( const QString d , QString DirStart );
    void MakeSubdirInfo( const QString infoxml , const QString path );
private:
    NetworkDav *dbdav;
    DavPROPFIND *xmlinfofile;  
    int numerazione;
    //////////////NetworkDav *dbdav;
    QSettings setter;
    int fnumerazione;
    QWidget *mainparent;
    QStringList subdirlist;
    QStringList MkdirLists;
    QList<File_Ram*> Onwaitfile;
    bool BeamUpsGo;  /* to take info from cache or net no upload stay false*/
 void Load_Connector();
signals:
 void BuildTreeFromRemote( QDomDocument d , QString path );
 void StatusPrint(QString x);
 void StopCicleFull();
 void ErrorBuil();
 void WakeUpFromList(QString);
public slots:
    void ShowMessageWarning( QString msg );
    void TreeInfo(  QDomDocument infoxml , const QString path );
    void SubinfoGrabPosition( int now  );
    void StopLoop();
    void SubTreeRegister( QString file ,QString path ,int pos );
    void ProcessPutList( QStringList xx , QString DirReload );
    void ProcessMkDirList( QStringList xx , QString DirReload );
    void ProcessVirtualMkDirList( QStringList xx , QString DirReload );
    /* put upload */
    void SendPutList( int now  );
    /* mkdir */
    void MkdirItemat( int now  , QString fmsg  );
    
    void ExitNextOperation();
    
    

    

    

};
//
#endif // BASEDAV_H

